import request from '@/libs/request';
let _self;
export const index =  {
	props: {
		orderId: {type: Number,default: 0},
		show: {type: Boolean,default: false},
		title: {type: String,default: ""},
		imgs: {type: Array,default: []},
		payData:{type: Object,default: {}}
	},
	data() {
		return {
			host:process.env.HOST,
			showBox:false,
			boxTitle:this.title,
			showConfirm:false,
			images:[],
			rules:{}
		}
	},
	
	
	watch:{
		show(val){
			this.showBox=val;
			if(val){
				this.initData();
			}
		},
		
		imgs(val){
			
			if(val){
				this.images=[];
				for(let index in val){
					this.images.push({"url":val[index]})
				}
			}
		},
	
		showBox(val){
			this.$emit('update:show', val);
		},
		title(val){this.boxTitle=val;},

	},
	created() {
		_self = this;

	},
	
	methods: {
		async initData(){

		},

		
		cancel(e){
			this.showBox=false;
		},
		confirmBox(e){
			//this.showConfirm=true;
			
			this.confirmCode();
			
		},
		submitForm(){},
		
		
		
		confirmCode: async function() {	
			
			if(this.images.length==0){
				uni.showToast({icon:"none",title:"请上传付款截图！"});
				return false;
			}
			
			let imgList=[];
			for(let index in this.images){
				let item=this.images[index].url;
				imgList.push(item);
			}
			
			let ret = await request({url: '/api/order/updataInfo',method: 'POST',data:{"id":this.orderId,"pay_imgs":imgList}});
			if(ret!="success"){
				uni.showToast({icon:"none",title:"更新订单图片失败！"});
				return false;
			}

			let payInfo=Object.assign({"confirm":false,"is_upload":true,"pay_imgs":imgList},this.payData);
			this.showBox=false;
			this.$emit('update:payData',{});
			this.$emit('update:payData',payInfo);
		}

	}
}